<h1>
	软件列表
</h1>
<button type="button" class="am-btn am-btn-primary" data-am-modal="{target: '#helperpop'}" data-dismiss="modal">
	API使用方法
</button>
<button type="button" class="am-btn am-btn-primary" data-am-modal="{target: '#addbox'}" data-dismiss="modal">
	添加软件
</button>
<br />
<br />
<br />
<?php
header("Content-type:text/html;charset=utf-8");
include "../action/getuid.php";
include '../action/setting.php';
$con = mysqli_connect($sqldatabase, $sqlusername, $sqlpassword, $sqltable);
mysqli_query($con, 'set names utf8');
$result = mysqli_query($con, "SELECT * FROM softlist where uid='" . $uid . "'");
$softname = array();
$softid = array();
$version = array();
$update = array();
$notice = array();
$description = array();
$cn = array();
while ($row = mysqli_fetch_array($result)) {
	$softname[] = $row["softname"];
	$softid[] = $row["softid"];
	$description[] = $row["description"];
	$version[] = $row["version"];
	$cn[] = $row["CheckNum"];
	$update[] = $row["up"];
	$notice[] = $row["notice"];
}

?>
<?php
$num = count($softid);
for ($i = 0; $i < $num; $i++) {
	$result = mysqli_query($con, "SELECT * FROM softlic where softid='" . $softid[$i] . "'");
	$usertoken = array();
	$lic_username = array();
	$is_can = array();
	while ($row = mysqli_fetch_array($result)) {
		$usertoken[] = $row["usertoken"];
		$lic_username[] = $row["usernam"];
		$is_can[] = $row["is_can"];
	}
	echo "<button style=\"float:right;margin-left: 10px;\" class=\"am-btn am-btn-primary editverbtm\" value=\"" . $softid[$i] . "\" type=\"submit\"><span class=\"glyphicon glyphicon-pencil\" aria-hidden=\"true\"></span> 修改</button>
<button value=\"" . $softid[$i] . "\" style=\"margin-left: 10px;float:right;\" class=\"am-btn am-btn-primary addlicbtm\"  type=\"submit\"><span class=\"glyphicon glyphicon-plus\" aria-hidden=\"true\"></span>  添加授权</button>
<button class=\"am-btn am-btn-warning delboxbtm\" style=\"float:right;\" value=" . $softid[$i] . " type=\"submit\"><span class=\"glyphicon glyphicon-minus\" aria-hidden=\"true\"></span>  删除软件</button>
<div id=\"a" . $softid[$i] . "\"><h1>" . $softname[$i] . "(" . $cn[$i] . " times)</h1>
<br/>
<div class='am-input-group'>
<span class='am-input-group-label'>API</span>
<input type=\"text\" value=\"http://dogma.syana.moe/ver.php?sid=" . $softid[$i] . "&ver=" . $version[$i] . "\" class=\"am-form-field\" placeholder=\"\" readonly>
</div>
<br/>
<div class='am-input-group'>
<span class='am-input-group-label'>版本检测</span>
<input type=\"text\" id=\"ver_" . $softid[$i] . "\" value=\"" . $version[$i] . "\" class=\"am-form-field\" placeholder=\"主版本号.子版本号.修正版本号.编译版本号\" >
</div>
<br/>
<div class='am-input-group'>
<span class='am-input-group-label'>更新地址</span>
<input type=\"text\" value=\"" . $update[$i] . "\" id=\"update_" . $softid[$i] . "\" class=\"am-form-field\" placeholder=\"输入http://...../\" >
</div>
<br/>
<div class='am-input-group'>
<span class='am-input-group-label'>软件公告</span>
<input type=\"text\" value=\"" . $notice[$i] . "\" id=\"notice_" . $softid[$i] . "\" class=\"am-form-field\" placeholder=\"软件公告啦\" >
</div>
<br/>
</div>
<table class=\"am-table am-table-bordered table-hover\">
<tr>
<td>用户名称</td>
<td>授权状态</td>
<td style=\"width:390px\">操作</td>
</tr>";
	$numi = count($usertoken);
	for ($o = 0; $o < $numi; $o++) {
		echo "<tr><td>" . $lic_username[$o] . "</td><td>" . $is_can[$o] . "</td><td>
<button class=\"am-btn am-btn-warning lic_del\" value=\"" . $usertoken[$o] . "\" type=\"submit\"><span class=\"glyphicon glyphicon-minus\" aria-hidden=\"true\"></span>  删除此授权</button>
<button class=\"am-btn am-btn-primary lic_ret\" value=\"" . $usertoken[$o] . "\" name=\"" . $is_can[$o] . "\" type=\"submit\"><span class=\"glyphicon glyphicon-refresh\" aria-hidden=\"true\"></span>  ";
		if ($is_can[$o] == "0") {
			echo "暂停此授权";
		} else {
			echo "重启此授权";
		}
		echo "</button>
<button class=\"am-btn am-btn-primary lic_getapi\" value=\"" . $usertoken[$o] . "\" type=\"submit\"><span class=\"glyphicon glyphicon-ok\" aria-hidden=\"true\"></span>  获取API</button>
</td></tr>";
	}
	echo "</table>
<br/>
<br/></div><br/> <hr data-am-widget='divider' class='am-divider am-divider-default' /><br/><br/>";
}
?>
<div class="am-popup" id="helperpop">
	<div class="am-popup-inner">
		<div class="am-popup-hd">
			<h4 class="am-popup-title">
				API使用方法
			</h4>
			<span data-am-modal-close
			class="am-close">&times;</span>
		</div>
		<div class="am-popup-bd">
			<div style="margin-bottom: 10px;text-align:left;">
				<h4>
					软件版本验证API
				</h4>
				<p>
					请复制软件下方API的编辑框
				</p>
				<img src="http://ww2.sinaimg.cn/large/cf7bb22egw1euprkommj3j20kw02mq39.jpg">
				<h4>
					软件授权验证API
				</h4>
				<p>
					请点击授权管理列表中的『获取API』
				</p>
				<img src="http://ww1.sinaimg.cn/large/cf7bb22egw1euprmu1iquj20jq0363yx.jpg">
				<p>
					之后请手动复制编辑框内容
				</p>
				<img src="http://ww3.sinaimg.cn/large/cf7bb22egw1euprou0qjyj20gk02qglv.jpg">
				<p>
					返回信息皆为JSON格式
				</p>
				<p>
					例：{"error_code":"2","error_msg":"\u6388\u6743\u9a8c\u8bc1\u5931\u8d25\uff0c\u6388\u6743\u4e0d\u5b58\u5728","update":"","notice":"","timestamp":1438610040}
				</p>
				<p>
					error_code 错误代码[0:正常、-1:非法访问、1:（版本）有新版本（授权）授权被暂停、2:（授权）授权被删除]
				</p>
				<p>
					error_msg 错误信息
				</p>
				<p>
					timestamp 时间戳
				</p>
				<p>
					update 更新地址
				</p>
				<p>
					notice 软件公告
				</p>
				<br/>
			</div>
		</div>
	</div>
</div>
<div class="am-popup" id="addbox" style="height: 270px;">
	<div class="am-popup-inner">
		<div class="am-popup-hd">
			<h4 class="am-popup-title">
				添加软件
			</h4>
			<span data-am-modal-close
			class="am-close">&times;</span>
		</div>
		<div class="am-popup-bd">
			<form>
				<div class="am-form-group">
					<label >软件名称：</label>
					<input type="text" style="width: 80%;" id="softname" placeholder="输入一个软件名称 （2-15字数，数字，英文，汉字）">
				</div>
				<div class="am-form-group">
					<label >软件版本：</label>
					<input type="text" style="width: 80%;"  value="1.0.0.0" id="softver" placeholder="主版本号.子版本号.修正版本号.编译版本号">
				</div>
				<div class="am-form-group">
					<label >软件描述：</label>
					<input type="text" style="width: 80%;"  value="我的软件" id="description" placeholder="输入一个软件描述 （2-100字数，数字，英文，汉字）">
				</div>
				<button type="button"  style="margin-left:5px; float:right;" id="addsoft" class="am-btn am-btn-success">
					添加
				</button>
			</form>
		</div>
	</div>
</div>
<div class="am-popup" id="addlicbox" style="height: 180px;">
	<div class="am-popup-inner">
		<div class="am-popup-hd">
			<h4 class="am-popup-title">
				添加授权
			</h4>
			<span data-am-modal-close
			class="am-close">&times;</span>
		</div>
		<div class="am-popup-bd">
			<form>
				<div class="am-form-group">
					<label >用户名称：</label>
					<input type="text" style="width: 80%;" id="lic_username" placeholder="输入一个名称（2-15字数，数字，英文，汉字）">
				</div>
				<button type="button" style="margin-left:5px; float:right;" id="addlic" class="am-btn am-btn-success">
					添加
				</button>
			</form>
		</div>
	</div>
</div>
<div class="am-popup" id="licapibox" style="height: 180px;">
	<div class="am-popup-inner">
		<div class="am-popup-hd">
			<h4 class="am-popup-title">
				API
			</h4>
			<span data-am-modal-close
			class="am-close">&times;</span>
		</div>
		<div class="am-popup-bd">
			<form>
				<div class="am-form-group">
					<label >API:</label>
					<input type="text" style="width: 90%;" id="lic_api" placeholder="" readonly>
				</div>
				
			</form>
		</div>
	</div>
</div>
<script type="text/javascript" src="../js/soft.js" >
</script>